<?php

	header ('Content-type: text/html; charset=ISO-8859-1'); 
	
//	include ('../config/validacao.php');

	// connect to the database server and select the appropriate database for use
	include ('../config/conexao.php');
	 
	// query the database table for zip codes that match 'term'
	$rs = mysql_query('SELECT idsetor, nomeSetor FROM setor WHERE secretaria_idsecretaria="'.$_GET['id'].'" ORDER BY nomeSetor ASC;');

	// loop through each zipcode returned and format the response for jQuery
	$data = array();
	if ( $rs && mysql_num_rows($rs) )
	{
		while( $row = mysql_fetch_array($rs) )
		{
			$idsetor = $row['idsetor'];
			$nomesetor = $row['nomeSetor'];

			$data [] = array('optionValue'=>$idsetor,'optionDisplay' =>utf8_encode($nomesetor));
			//$data[] = array('value' =>$row['nomecontato'].','.$row['cargo'].','.$row['sigla'].','.$row['nomeSetor'].','.$row['ramal'].','.$row['email']);
		}
	}
	
	
	// jQuery wants JSON data
	echo json_encode($data);
	

?>
